function ctrlInitArrowTableEditableColumn(context, selector, datain){
	
	var popup = null;
	
	$(".ctrl-table-cell-edit-text, .ctrl-table-cell-edit-textarea", context).click(function(){
		if(popup)
			popup.remove();
		
		var cell = $(this);
		var target = cell.find(".ctrl-table-cell-edit-value").clone();
		popup = cell.popup({
			el: target,
			open: true,
			autoHide: false
		});
		target.focus();
		var submit = $("<div>&nbsp;</div>").addClass("ctrl-table-cell-edit-submit");
		var cancel = $("<div>&nbsp;</div>").addClass("ctrl-table-cell-edit-cancel");
		target.after(submit);
		target.after(cancel);
		cancel.click(function(){
			popup.remove();
		});
		submit.click(function(){
			var data = {};
			data[target.attr("field")] = target.val();
			ArrowDataConnector.saveObjectData( target.attr("model"), target.attr("key"), data, {}, function(){
				var fc = cell.find(".ctrl-table-cell-edit-presenter")
				fc.text(target.val());
				popup.remove(); 
				if( datain.refresh ) {
					CtrlAjax.changeStateVars(fc,{},{},function(){});
				}
			} );
		});
	});
	
	/*
	$(".ctrl-table-cell-edit-boolswitch", context).each( function() { 
		var title = $( "a", $(this) ).attr("title") ;
		if( title ) {
			$(this).tooltip({ 
			    bodyHandler: function() { 
			  		return title ;
			    }, 
			    showURL: false 
			});
		}
   } )
   ;*/
	
	$(".ctrl-table-cell-edit-boolswitch").click(function(){
		
		var el = $(".ctrl-table-cell-edit-switch", this);
		var newVal = 1;
		if(el.is( ".ctrl-table-cell-edit-on" ))
			newVal = 0;
		
		var data = {};
		data[el.attr("field")] = newVal;
		ArrowDataConnector.saveObjectData( el.attr("model"), el.attr("key"), data, {}, function(){
			if(newVal == 0)
				el.removeClass("ctrl-table-cell-edit-on").addClass("ctrl-table-cell-edit-off");
			else
				el.removeClass("ctrl-table-cell-edit-off").addClass("ctrl-table-cell-edit-on");
		});
		
		return false;
	});
	
	$(".ctrl-table-cell-edit-select", context).click(function(){
		if(popup)
			popup.remove();
		
		var cell = $(this);
		var target = cell.find(".ctrl-table-cell-edit-value-cont").clone().css({'float': "left", display: 'block'});
		popup = cell.popup({
			el: target,
			open: true,
			autoHide: false
		});
		target.focus();
		target.css("display", "block");
		var submit = $("<div>&nbsp;</div>").addClass("ctrl-table-cell-edit-submit");
		var cancel = $("<div>&nbsp;</div>").addClass("ctrl-table-cell-edit-cancel");
		target.after(submit);
		target.after(cancel);
		cancel.click(function(){
			popup.remove();
		});
		submit.click(function(){
			var data = {};
			data[target.attr("field")] = target.find("select").val();
			ArrowDataConnector.saveObjectData( target.attr("model"), target.attr("key"), data, {}, function(){
				var fc = cell.find(".ctrl-table-cell-edit-presenter") ;
				fc.text(target.find("select").find(":selected").text());
				popup.remove();
				if( datain.refresh ) {
					CtrlAjax.changeStateVars( fc ,{},{});
				}
			} );
		});		
		
		return false;
	});
	
	/*
	
	$(selector,context).find(".ctrl-table-cell-edit-presenter").click(function(){
		var presenter = $(this);
		var editor = $(this).parent().find(".ctrl-table-cell-edit-value-cont");
		
		if($(".ctrl-table-cell-edit-on", $(this).parent()).length > 0){
			presenter.hide();
			editor.find("a").click();
			return;
		}
		
		editor.show();
		presenter.hide();
		$(this).parents("td").eq(0).find("input").focus().select();
		
		editor.mouseleave(function(){
			if(editor.find("select").length == 0){
				editor.hide();
				presenter.show();
			}
		})
	})
	
	
	
	$(selector,context).find( "a" ).click(function(){
		var link = $(this);
		var val = link.parent().find("input,select").val();
		var _switch = link.parent().find(".ctrl-table-cell-edit-switch");
		if( _switch.length > 0 ){
			if( _switch.hasClass("ctrl-table-cell-edit-on") )
				val="1";
			else
				val="0";
		}
		
		
		var text = link.parent().find("select :selected").text();
		text = (text)?text:val;
		var href = link.attr("href").replace("#value#", val);
		link.hide();
		link.parent().find(".ctrl-table-cell-edit-indicator").css('background-color', 'red');
		$.get( href, {}, function(){
			link.show();
			link.parent().find(".ctrl-table-cell-edit-indicator").css('background-color', 'green');
			var editer = link.parents("td").eq(0).find(".ctrl-table-cell-edit-value-cont").hide();
			var presenter = link.parents("td").eq(0).find(".ctrl-table-cell-edit-presenter");
			var _switch =  editer.find(".ctrl-table-cell-edit-switch");
			
			if( _switch.length > 0 ){
				editer.prepend(presenter.find("div"));
				presenter.append( _switch.eq(0) ).show();
				
			}else{
				presenter.text(text).show();
			}
		});
		return false;
	});
	*/
}

